//
//  LGConsultRecordBasicCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/18.
//  咨询记录 - 基本信息

#import "LGConsultRecordBasicCell.h"

#define lineHeight   viewPix(33)

@interface LGConsultRecordBasicCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UILabel *timeTitle;
/**   */
@property (nonatomic , strong)UILabel *timeLabel;
/**   */
@property (nonatomic , strong)UILabel *nameTitle;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *numberTitle;
/**   */
@property (nonatomic , strong)UILabel *numberLabel;
/**   */
@property (nonatomic , strong)UIButton *doctorTitle;
/**   */
@property (nonatomic , strong)UITextField *doctorTF;
/**   */
@property (nonatomic , strong)UIImageView *tipView;
/**  就诊序号 */
@property (nonatomic , strong)UIButton *indexTitle;
/**   */
@property (nonatomic , strong)UILabel *unitLabel;

@end

@implementation LGConsultRecordBasicCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setCanEdit:(BOOL)canEdit{
    _canEdit = canEdit;
    self.doctorTitle.selected = canEdit;
    self.indexTitle.selected = canEdit;
    self.tipView.hidden = !canEdit;
    self.unitLabel.hidden = !canEdit;
    self.doctorBtn.userInteractionEnabled = canEdit;
    self.indexTF.userInteractionEnabled = canEdit;
    self.doctorTF.placeholder = (canEdit == YES)?@"请选择":@"";
    self.indexTF.placeholder = (canEdit == YES)?@"请输入":@"";
    CGFloat doctorW = (canEdit == YES)?(Screen_W-viewPix(159)):(Screen_W-viewPix(147));
    CGFloat indexW = (canEdit == YES)?(Screen_W-viewPix(164)):(Screen_W-viewPix(147));
    self.doctorTF.frame = CGRectMake(kMinX(self.timeLabel.frame), kMaxY(self.numberLabel.frame), doctorW, lineHeight);
    self.indexTF.frame = CGRectMake(kMinX(self.timeLabel.frame), kMaxY(self.doctorTF.frame), indexW, lineHeight);
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.timeLabel.text = LGNSString(dataDic[@"followup_date"]);
    self.nameLabel.text = LGNSString(dataDic[@"realname"]);
    self.numberLabel.text = LGNSString(dataDic[@"hospital_bano"]);
    self.doctorTF.text = LGNSString(dataDic[@"doctor_name"]);
    self.indexTF.text = LGNSString(dataDic[@"followup_no"]);
    
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.baseView];
    [self.baseView addSubview:self.timeTitle];
    [self.baseView addSubview:self.timeLabel];
    [self.baseView addSubview:self.nameTitle];
    [self.baseView addSubview:self.nameLabel];
    [self.baseView addSubview:self.numberTitle];
    [self.baseView addSubview:self.numberLabel];
    [self.baseView addSubview:self.doctorTitle];
    [self.baseView addSubview:self.doctorTF];
    [self.baseView addSubview:self.tipView];
    [self.baseView addSubview:self.doctorBtn];
    [self.baseView addSubview:self.indexTitle];
    [self.baseView addSubview:self.indexTF];
    [self.baseView addSubview:self.unitLabel];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.height.equalTo(@(lineHeight*5+viewPix(6)));
    }];
    [self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.baseView).offset(-viewPix(15));
        make.centerY.equalTo(self.doctorTF);
        make.width.height.equalTo(@(viewPix(12)));
    }];
    [self.doctorBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(self.doctorTF);
    }];
    [self.unitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.baseView).offset(-viewPix(15));
        make.centerY.equalTo(self.indexTF);
    }];
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:0];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UILabel *)timeTitle{
    if(!_timeTitle){
        _timeTitle = [UILabel lableWithText:@"咨询时间" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        _timeTitle.frame = CGRectMake(viewPix(12), viewPix(6), viewPix(80), lineHeight);
    }
    return _timeTitle;
}

-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentRight lines:1];
        _timeLabel.frame = CGRectMake(viewPix(100), viewPix(6), Screen_W-viewPix(147), lineHeight);
    }
    return _timeLabel;
}

-(UILabel *)nameTitle{
    if(!_nameTitle){
        _nameTitle = [UILabel lableWithText:@"患者姓名" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        _nameTitle.frame = CGRectMake(kMinX(self.timeTitle.frame), kMaxY(self.timeTitle.frame), viewPix(80), lineHeight);
    }
    return _nameTitle;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentRight lines:1];
        _nameLabel.frame = CGRectMake(kMinX(self.timeLabel.frame), kMaxY(self.timeLabel.frame), Screen_W-viewPix(147), lineHeight);
    }
    return _nameLabel;
}

-(UILabel *)numberTitle{
    if(!_numberTitle){
        _numberTitle = [UILabel lableWithText:@"登记号" colorString:@"#333333" textFont:LGFontWeight(15, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        _numberTitle.frame = CGRectMake(kMinX(self.timeTitle.frame), kMaxY(self.nameTitle.frame), viewPix(80), lineHeight);
    }
    return _numberTitle;
}

-(UILabel *)numberLabel{
    if(!_numberLabel){
        _numberLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentRight lines:1];
        _numberLabel.frame = CGRectMake(kMinX(self.timeLabel.frame), kMaxY(self.nameLabel.frame), Screen_W-viewPix(147), lineHeight);
    }
    return _numberLabel;
}

-(UIButton *)doctorTitle{
    if(!_doctorTitle){
        _doctorTitle = [UIButton buttonWithTitle:@"接诊医生" titleFont:LGFontWeight(15, UIFontWeightMedium) normalColor:@"#333333" selectColor:@"#333333" normalImage:@"" selectImage:@"必选项"];
        _doctorTitle.frame = CGRectMake(kMinX(self.timeTitle.frame), kMaxY(self.numberTitle.frame), viewPix(80), lineHeight);
        _doctorTitle.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _doctorTitle.userInteractionEnabled = NO;
    }
    return _doctorTitle;
}

-(UITextField *)doctorTF{
    if(!_doctorTF){
        _doctorTF = [[UITextField alloc]initWithFrame:CGRectMake(kMinX(self.timeLabel.frame), kMaxY(self.numberLabel.frame), Screen_W-viewPix(147), lineHeight)];
        _doctorTF.tintColor = [UIColor colorWithString:@"#666666"];
        _doctorTF.textColor = [UIColor colorWithString:@"#666666"];
        _doctorTF.textAlignment = NSTextAlignmentRight;
        _doctorTF.keyboardType = UIKeyboardTypeNumberPad;
        _doctorTF.userInteractionEnabled = NO;
        _doctorTF.placeholder = @"请选择";
        _doctorTF.font = LGFont(14);
    }
    return _doctorTF;
}

-(UIImageView *)tipView{
    if(!_tipView){
        _tipView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"grayTip12"]];
        _tipView.hidden = YES;
    }
    return _tipView;
}

-(UIButton *)doctorBtn{
    if(!_doctorBtn){
        _doctorBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    }
    return _doctorBtn;
}

-(UIButton *)indexTitle{
    if(!_indexTitle){
        _indexTitle = [UIButton buttonWithTitle:@"咨询序号" titleFont:LGFontWeight(15, UIFontWeightMedium) normalColor:@"#333333" selectColor:@"#333333" normalImage:@"" selectImage:@"必选项"];
        _indexTitle.frame = CGRectMake(kMinX(self.timeTitle.frame), kMaxY(self.doctorTitle.frame), viewPix(80), lineHeight);
        _indexTitle.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _indexTitle.userInteractionEnabled = NO;
    }
    return _indexTitle;
}

-(UITextField *)indexTF{
    if(!_indexTF){
        _indexTF = [[UITextField alloc]initWithFrame:CGRectMake(kMinX(self.timeLabel.frame), kMaxY(self.doctorTF.frame), Screen_W-viewPix(147), lineHeight)];
        _indexTF.tintColor = [UIColor colorWithString:@"#666666"];
        _indexTF.textColor = [UIColor colorWithString:@"#666666"];
        _indexTF.textAlignment = NSTextAlignmentRight;
        _indexTF.keyboardType = UIKeyboardTypeNumberPad;
        _indexTF.placeholder = @"请输入";
        _indexTF.font = LGFont(14);
    }
    return _indexTF;
}

-(UILabel *)unitLabel{
    if(!_unitLabel){
        _unitLabel = [UILabel lableWithText:@"号" colorString:@"#333333" textFont:LGFontWeight(13, UIFontWeightMedium) textAlignment:NSTextAlignmentRight lines:1];
        _unitLabel.hidden = YES;
    }
    return _unitLabel;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
